<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title><?php echo ($title); ?></title>
    <link rel="stylesheet" href="/Public/web/css/pintuer.css">
    <link rel="stylesheet" href="/Public/web/css/admin.css">
    <script src="/Public/web/js/jquery.js"></script>
    <script src="/Public/web/js/pintuer.js"></script>
</head>

<body>
  <div class="panel admin-panel">
    <div class="body-content">
      <form method="post" class="form-x" action="" enctype="multipart/form-data">

        <div class="form-group">
          <div class="label">
            <label>名称：</label>
          </div>
          <div class="field">
            <input type="text" class="input w50" value="<?php echo ($info['bannar_name']); ?>" name="bannar_name" data-validate="required:<?php echo L('qingshuru'); echo L('shangpinmingcheng');?>" />
            <div class="tips"></div>
          </div>
        </div>

        <div class="form-group">
          <div class="label">
            <label><?php echo L("suolvetu");?>：</label>
          </div>
          <div class="field">
            <input type="file" class="button bg-blue" name="bannar_img" value="+ <?php echo L('linlanshangchuan');?>" onchange="preview(this)" style="float: left;"><span style="color: #777;">建议：750*300</span>
            <div id="preview" name="img" style="float: left;width: 10%;box-sizing: border-box;" class="input">
              <?php if(empty($info['default_img'])): ?><img src="/Public/images/zanwu.jpg" width="100%" alt=""/>
                <?php else: ?>
                <img src="/<?php echo ($info['bannar_img']); ?>" width="100%" alt=""/><?php endif; ?>
            </div>
            <div class="tipss"></div>
          </div>
        </div>


        <div class="form-group">
          <div class="label">
            <label><?php echo L("paixu");?>：</label>
          </div>
          <div class="field">
            <input type="text" class="input w50" name="sort" value="<?php echo ($info['sort']); ?>" data-validate="number:<?php echo L('hefapaixu');?>" />
            <div class="tips"></div>
          </div>
        </div>

        <div class="form-group">
          <div class="label">
            <label></label>
          </div>
          <div class="field">
            <button class="button bg-main icon-check-square-o" type="submit"> <?php echo L("tijiao");?></button>
          </div>
        </div>

      </form>
    </div>
  </div>
  <script type="text/javascript">
    $(document).ready(function(){
      $("select[name='goods_type']").change(function(){
        var typeon = $("select[name='goods_type']").val();
        if(typeon==1){$("#mytype").show();}
        else{$("#mytype").hide();$("#mytypeitem").hide();}
      });

      $(".mya1").click(function(){
        var html = '<div class="form-group"> ';
        html += '<div class="label"><label></label></div>';
        html += '<div class="field"> ';
        html += '<input type="text" class="Father_Title input w50" name="spec_name[]" placeholder="<?php echo L("guigemingchen");?>" data-validate="required: " />　';
        html += ' <input type="text" class="input w50 check_item" name="item_name[]" placeholder="<?php echo L("guigeshuxing");?>" data-validate="required: " />　';
        html += ' <a href="javascript:void(0)" class="mya1 button bg-red" onclick="itemdel(this)"><?php echo L("shanchuguige");?></a>';
        html += '</div></div>';

        $("#mytype").append(html);
      });
    });

    function preview(file)
    {
      var prevDiv = document.getElementById('preview');
      if (file.files && file.files[0])
      {
        var reader = new FileReader();
        reader.onload = function(evt){
          prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="100%" />';
        }
        reader.readAsDataURL(file.files[0]);
      }
      else
      {
        prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
      }
    }
    //单个删除
    function del(id,goods_id,t){
      if(confirm("<?php echo L('shanchuxiaoxi');?>")){
        var url = "<?php echo U('goods/delpic');?>";
        $.getJSON(url,{id:id,goods_id:goods_id},function (data){
          if(data.result=="true1"){$(t).remove();}
          else if(data.result=="true2"){$(t).next('input[type=hidden]').remove();$(t).remove();}
        })
      }
    }
    function itemdel(t){
      $(t).parents('.form-group').remove();
    }
    //生成表格
    function refreshOptions(){
      $("#mytypeitem").show();
      step.Creat_Table();
    }
  </script>
</body>
</html>